﻿<UserControl x:Class="CommonUtilities.Controls.CUtil_TitleBar"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:conv="clr-namespace:CommonUtilities.Converters"
             mc:Ignorable="d" Height="23"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <conv:UIOffsetConverter x:Key="UIOffsetConverter" />
    </UserControl.Resources>

    <Grid Name="grdMain" Background="LightGray">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.Resources>
            <Style x:Key="AppIconStyle" TargetType="Image">
                <Setter Property="Height" Value="20" />
                <Setter Property="Width">
                    <Setter.Value>
                        <Binding ElementName="grdMain" Path="ActualHeight" />
                        <!--Converter="{StaticResource UIOffsetConverter}" ConverterParameter="2" FallbackValue="20" />-->
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="{x:Type ButtonBase}" x:Key="WindowResizeButtonStyle">
                <Setter Property="Margin" Value="-0.5,0" />
                <Setter Property="Cursor" Value="Hand"/>
                <Setter Property="SnapsToDevicePixels" Value="true"/>
                <Setter Property="OverridesDefaultStyle" Value="true"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate x:Name="ctemp" TargetType="{x:Type Button}">
                            <ContentPresenter Name="cpres" />
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter TargetName="cpres" Property="Opacity" Value="0.8" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <!--<Style x:Key="grayedIfNotLogged" TargetType="Image">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding StatusInfo.IsLogged}" Value="False">
                        <Setter Property="Effect">
                            <Setter.Value>
                                <fx:GreyscaleEffect />
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                </Style.Triggers>
            </Style>-->
        </Grid.Resources>

        <Image Name="imgLogo" Margin="3,0" Style="{StaticResource AppIconStyle}" />
        <TextBlock Name="txtbTitle" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" Padding="3,1" />
        <StackPanel Grid.Column="2" Margin="3,0" Orientation="Horizontal">
            <Button Name="btnMinimize" Style="{StaticResource WindowResizeButtonStyle}" Click="btnMinimize_Click">
                <Image Style="{StaticResource AppIconStyle}" 
                       Source="pack://application:,,,/CommonUtilities;component/Images/window_minimize.png" />
            </Button>
            <Button Name="btnMaximize" Style="{StaticResource WindowResizeButtonStyle}" Click="btnMaxRestore_Click">
                <Image Style="{StaticResource AppIconStyle}" 
                       Source="pack://application:,,,/CommonUtilities;component/Images/window_maximize.png" />
            </Button>
            <Button Name="btnRestore" Style="{StaticResource WindowResizeButtonStyle}" Click="btnMaxRestore_Click">
                <Image Style="{StaticResource AppIconStyle}" 
                       Source="pack://application:,,,/CommonUtilities;component/Images/window_restore.png" />
            </Button>
            <Button Name="btnClose" Style="{StaticResource WindowResizeButtonStyle}" Click="btnClose_Click">
                <Image Style="{StaticResource AppIconStyle}" 
                       Source="pack://application:,,,/CommonUtilities;component/Images/window_close.png" />
            </Button>
        </StackPanel>
    </Grid>
</UserControl>
